package com.softer.chengxin.enterprise.dao.provider;

import com.softer.chengxin.enterprise.entity.Enterprise;
import org.apache.commons.lang3.StringUtils;

import java.util.Map;

/**
 * @author Gong Zhiyang
 * @date 2019/12/12
 */

public class EnterpriseDaoProvider {
    /**
     * 查询列表
     * @param map 查询参数
     * @return SQL
     */
    public String getList(Map<String, Enterprise> map){
        StringBuilder sql = new StringBuilder(10);
        Enterprise en = map.get("en");
        sql.append("SELECT id,`name`,`code`,remark,info_id as infoId,legal_person as legalPerson,area,gmt_create as gmtCreate,");
        sql.append("creater,gmt_modify as gmtModify,modifier FROM enterprises_lack_info WHERE 1=1");
        if (StringUtils.isNotBlank(en.getName())){
            sql.append(" and INSTR(`name`,#{en.name})>0 ");
        }
        if (StringUtils.isNotBlank(en.getArea())){
            sql.append(" and INSTR(`area`,#{en.area})>0 ");
        }
        return sql.toString();
    }
}
